import {Base} from '../../utils/base.js';
class User extends Base{
  constructor()
  {
    super();
  }

  //获取用户信息
  getUserInfo(uid,callback)
  {
    var that =this;
    var params = {
      url:"user_info?uid="+uid,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //获取用户待付款的订单
  getOrderByType(type,uid,callback)
  {
    var that =this;
    var params = {
      url:"order/type?type="+type+'&uid='+uid,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //取消订单
  cancelOrder(id,callback)
  {
     var that =this;
    var params = {
      url:"order/cancel?id="+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //确认收货
  confirmOrder(id,callback)
  {
    var that =this;
    var params = {
      url:"order/confirm?id="+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //订单完成后选择归还手机
  returnProduct(id,callback)
  {
    var that =this;
    var params = {
      url:"order/return?id="+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //订单完成后买断手机
  buyProductAfterOrder(id,callback)
  {
    var that =this;
    var params = {
      url:"order/buy_product?id="+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //订单完成后获取预支付订单信息
  getReturnPreOrder(orderId,orderNo,callback)
  {
     var that =this;
    var params = {
      url:"pay/return_pay?orderId="+orderId+'&orderNo='+orderNo,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }
  //买断后支付回调
  returnNotify(orderid,callback)
  {
     var that =this;
     var params = {
      url:"return/notify?orderid="+orderid,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //获取我的归还列表
  getMyreturn(callback)
  {
     var that =this;
    var params = {
      url:"return/myreturn",
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }
}
export {User};